// 导入 express 模块
const express = require("express");
const cors = require("cors");
const getDataMiddleWare = require("./middleware");

// 定义端口号
const PORT = 9898;

// 创建 express 应用
const app = express();

app.use(cors()); //解决跨域
// 解析JSON数据
app.use(express.json());

// 解析application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true }));

// app.get("*", getDataMiddleWare);
// app.post("*", getDataMiddleWare);
app.all("*",getDataMiddleWare);

// 启动服务器
app.listen(PORT, () => {
  console.log(`Server is running on http://192.168.2.122:${PORT}`);
});
